import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

//为了方便测试，此处用vuex做全局数据
const store = new Vuex.Store({
	state:{
		popustatus: false,
		userinfo: JSON.parse(uni.getStorageSync('userinfo')||'{}'),
		address: '123',
		shoppingCar: false,
		shoppingSumPrice: 0,
		shoppingData: [],
		shoppingCarData:[],
		shoppingCarNum: 0
	},
	mutations:{
		initShopping(state,data){
			console.log(data,'shopping')
			state.shoppingData = data
		},
		//判断购物车是否有重复商品,有的话购买总数加一
		addShoping(state,index){
			console.log(state.shoppingCarData[index].goodsNum,"前")
			state.shoppingCarData[index].goodsNum = state.shoppingCarData[index].goodsNum +1
			console.log(state.shoppingCarData[index].goodsNum,11111222222233333333)
		}
	}
})
export default store
